<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/vectrics.tld" prefix="vectrics" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

<%@ page import="org.vectrics.user.UserAuthService" %>
<%@ page import="org.vectrics.provider.*" %>
<%@ page import="org.vectrics.user.*" %>
<%@ page import="org.vectrics.recruiter.config.RecruitConfig" %>
<%@ page import="org.vectrics.domain.Domain" %>
<%@ page import="org.vectrics.hibernate.ThreadProperties" %>
<%@ page import="org.vectrics.struts.*" %>


<%
	Request vectricsRequest = HttpRequestConverter.convertRequest(request);
	String domainId = ThreadProperties.getUriDomainId();
	Domain domain = ThreadProperties.getDomain();
	String uploadResumeHref = "/hrs-public/profile/" + domainId + "/resume/showUpload.do";
	String editResumeHref = "/hrs-public/profile/" + domainId + "/edit_resume.do";
	String profileEditHref = "/hrs-public/profile/" + domainId + "/edit.do";
	String agentListHref = "/hrs-public/profile/" + domainId + "/agent/list.do";
	String passwordEditHref = "/hrs-public/profile/" + domainId + "/passwordedit.do";
	String cvHref = "/hrs-public/cv/" + domainId + "/index.do";
	String estudiosEditHref = "/hrs-public/cv/" + domainId + "/studies.do";
	String experienceHref = "/hrs-public/cv/" + domainId + "/experience.do";
	
	Person person = CoreServiceLocator.getUserAuthService().getAuthorizedPerson(vectricsRequest);

	if (person == null) {
		person = CoreServiceLocator.getPersonService().findPersonWithUserName(domain, request.getParameter("userName"));
	}
	
	User user = person.getUser();
	String userId = null;
	if (user != null) {
		userId = person.getId().toString();		
	}
	else {
%>
		<h1><bean:message key="phrase.no.authorized.user.logged.in"/></h1>
<%
	}
	boolean allowAgents = RecruitConfig.getRecruitInstance().getAllowJobAgents(domain);
	boolean allowResumes = RecruitConfig.getRecruitInstance().getAllowPublicResumeSubmit(domain);
%>

<table width="100%">	<tr><td class="sectionHdrBg">
	<font class="sectionHdrFont">Profile Information</font>
</td></tr></table>

<vectrics:recruitUserSummary 
		personId="<%=userId%>" 
		showResumeCount="false" 
		showInterviewCount="false"
		showHomeAddress="false"
		showCandidateLocations="true"/>

<table cellspacing="5" >
	<tr>
		<td >
			<vectrics:button 
					href="<%=profileEditHref%>"
					code="public.button.wide"
					phraseCode="button.user.profile.change"					
					paramName="userId"
					paramValue="<%=userId%>"
					/>
		</td>

		<td>
			<vectrics:button 
					href="<%=passwordEditHref%>"
					code="public.button.wide"
					phraseCode="button.password.change"					
					paramName="personId"
					paramValue="<%=userId%>"
					/>
		</td>

<% if (allowAgents) { %>
		<td>
			<vectrics:button 
					href="<%=agentListHref%>"
					code="public.button.wide"
					phraseCode="button.search.agents.view"					
					paramName="personId"
					paramValue="<%=userId%>"
					/>
		</td>
<% } %>		
		
	</tr>
  <tr>
    <td>
        <vectrics:button 
					href="<%=estudiosEditHref%>"
					code="public.button.wide"
					phraseCode="button.person.studies"					
					paramName="personId"
					paramValue="<%=userId%>"
					/>
	</td>
	<td>
        <vectrics:button 
					href="<%=experienceHref%>"
					code="public.button.wide"
					phraseCode="button.person.experience"					
					paramName="personId"
					paramValue="<%=userId%>"
					/>
	</td>
	<td>
        <vectrics:button 
					href="<%=agentListHref%>"
					code="public.button.wide"
					phraseCode="button.search.agents.view"					
					paramName="personId"
					paramValue="<%=userId%>"
					/>
	</td>
  </tr>
</table>


<% if (allowResumes) { %>
	<br>
	<table width="100%">	<tr><td class="sectionHdrBg">
		<font class="sectionHdrFont">Resume(s)</font>
	</td></tr></table>
	<br>
	<vectrics:userResumeList userId="<%=userId%>" />
	<br>
	<table cellspacing="5">
		<tr>
			<td>
				<vectrics:button 
						href="<%=uploadResumeHref%>"
						code="public.button.wide"
						phraseCode="button.resume.upload.new"					
						paramName="userId"
						paramValue="<%=userId%>"
						/>
			</td>
			<td>
				<vectrics:button 
						href="<%=editResumeHref%>"
						code="public.button.wide"
						phraseCode="button.resume.text.enter"					
						paramName="userId"
						paramValue="<%=userId%>"
						/>
			</td>
			<td>
			<vectrics:button 
					href="<%=cvHref%>"
					code="public.button.wide"
					phraseCode="button.cv"					
					paramName="userId"
					paramValue="<%=userId%>"
					/>
		   </td>
		</tr>
	</table>
<% } %>




